import logging

from system import System
from utils import get_args

# FIXME hide ffmpeg logs
SYSTEM_ALERT_INTERVAL = get_args("system_alert_interval")
ENV = get_args("env")
LOGGING_CONFIG = get_args(f"{ENV}_logging_config")
MEMCACHE_URL = get_args("memcache_url")
if ENV == "dev":
    logging.basicConfig(
        format=LOGGING_CONFIG["format"],
        level=LOGGING_CONFIG["level"],
        datefmt=LOGGING_CONFIG["date_format"],
    )
else:
    logging.basicConfig(
        filename="system.log",
        format=LOGGING_CONFIG["format"],
        level=LOGGING_CONFIG["level"],
        datefmt=LOGGING_CONFIG["date_format"],
    )

system = System(MEMCACHE_URL, SYSTEM_ALERT_INTERVAL)
if get_args("env") == "dev":
    system.set_task()
system.run()
